import { createApp } from 'vue'
import App from './App.vue'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import router from "@/router/router.js"
import 'element-plus/dist/index.css'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import ElementPlus from 'element-plus'
import { createPinia } from 'pinia'
import _ from "lodash";
import Cookies from 'js-cookie';
import { tabSelection } from '@/tool/status.js'

window.__proto__._ = _;// 挂载全局
window.__proto__.Cookies = Cookies;
Array.prototype.empty = function () {
    return !this || this.length === 0;
}
// 注册图标全局
const app = createApp(App)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}
const pinia = createPinia();
app.use(router)
app.use(pinia)
app.use(ElementPlus, {
    locale: zhCn
});

const tab= tabSelection();
router.beforeResolve(async (to) => {
    let param = to.query.id;
    if(param){
       await tab.save(to.query.id);
    }
});
app.mount('#app')
